package com.da.javatest.demo.basic;

/**
 * @author chenlida
 * @date 2019/3/4 10:05
 * @description
 */
public class Load {
    private static String str;

    static {
        System.out.println("hello");
        str = "ccc";
    }

    private Load() {}

    public static String getStr() {
        return str;
    }

    private static class LazyHolder {
        static final Load INSTANCE = new Load();
    }

    public static Load getInstance() {
        return Load.LazyHolder.INSTANCE;
    }

    public static void main(String[] args) {
        System.out.println(Load.getStr());
        new Load();
        System.out.println("after new");
        new Load();
        System.out.println(Load.getInstance());
        System.out.println(Load.getInstance());
    }

}
